import {getWUXILocation, getRandomDateTime, getRandomInt, getLastMonthDates} from "./utils";
import Mock from "mockjs";


let warning_data = {
    cycle_coming_numb: 100,
    long_time_door_open: 20,
    people_number_out: 10,
    in_elevtor: 3,
    other: 6,
    total_numb: 0
}

function getWarning(): {} {
    warning_data.total_numb =
        warning_data.cycle_coming_numb +
        warning_data.other +
        warning_data.people_number_out +
        warning_data.long_time_door_open +
        warning_data.in_elevtor
    return warning_data
}

enum state_list {
    Maintained = "已维保",
    NOMaintained = "未维保",
    Maintenancing = "维保中",
    Fault = "故障",
    Suspended = "暂停使用"
}
const red="rgb(183,32,99)"
enum state_color {
    Maintained = "green",
    NOMaintained = red,
    Maintenancing = "rgb(243,165,70)",
    Fault = red,
    Suspended = red
}

var state: string[] = [
    state_list.Maintained,
    state_list.NOMaintained,
    state_list.Maintenancing,
    state_list.Fault,
    state_list.Suspended,
]
var color: string[] = [
    state_color.Maintained,
    state_color.NOMaintained,
    state_color.Maintenancing,
    state_color.Fault,
    state_color.Suspended,
]

let accumulated_miles = {
    location: "",
    latest_time: "",
    state: "",
    color: "",
    distance: 0
}


function get_miles_counts(): any[] {
    var rst: any[] = []
    let distance: number = getRandomInt(8000, 9000);
    for (let i = 0; i < 100; i++) {
        let location: string = getWUXILocation()
        let latest_time: string = getRandomDateTime()
        distance = distance-getRandomInt(50, 80);
        let randomNumber = getRandomInt(0, 4);
        let state_ = state[randomNumber]
        let color_ = color[randomNumber]
        accumulated_miles = {
            location: location,
            latest_time: latest_time,
            state: state_,
            color: color_,
            distance: distance
        }
        rst.push(accumulated_miles)
    }
    return rst
}


function get_fault_static(): any {
    let dateTime: string[] = []

    let canNumb: number[] = []
    let bottleNumb: number[] = []
    let paperNumb: number[] = []

    for (let i = 0; i < 6; i++) {
        canNumb.push( getRandomInt(20, 100))
        bottleNumb.push(getRandomInt(40, 200))
        paperNumb.push( getRandomInt(50, 300))
    }
    dateTime=["7月","8月","9月","10月","11月","12月"]
    return {
        canNumb: canNumb,
        bottleNumb: bottleNumb,
        paperNumb: paperNumb,
        dateTime: dateTime,
        year:'2'
    }
}

function getFixHistory():any{
    var rst: any[] = []
    let info_list: string[] = [
        "纸板柜已满  回收完成",
        "塑料瓶柜已满  回收完成",
        "易拉罐柜已满  回收完成",
       ];
    for (let i = 0; i < 100; i++) {
        let location: string = getWUXILocation()
        let create_time: string = getRandomDateTime()
        let info: string = info_list[getRandomInt(0,9)];
        let state : int =  getRandomInt(0,1);
        let data = {
            location: location,
            create_time: create_time,
            info: info,
            state: state,
            device_id:10000+i
        }
        rst.push(data)
    }
    return rst
}

export {get_miles_counts, getWarning,get_fault_static,getFixHistory}

